#if !defined(__APP_BUFFER_H)
#define __APP_BUFFER_H

#include "pthread.h"

typedef struct
{
    unsigned char *ptr;
    int total_size;
    int data_len;
}Sub_buffer_t;

typedef struct 
{
    Sub_buffer_t *sub_buffer[2];
    int read_index;
    int write_index;
    pthread_mutex_t read_lock;
    pthread_mutex_t write_lock;
}Buffer_t;

Buffer_t* app_buffer_init(int size);

void app_buffer_destroy(Buffer_t *buffer);

int app_buffer_write(Buffer_t *buffer,char *data, int len);

int app_buffer_read(Buffer_t *buffer,char *data_buf, int buf_size);

#endif // __APP_BUFFER_H
